package com.woan.api.idao.dao;

import java.util.List;
import org.hibernate.LockMode;
import org.hibernate.Query;
import org.hibernate.Session;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.woan.api.idao.ZbControlIDAO;
import com.woan.api.model.SysVideo;
import com.woan.api.model.ZbControl;

/**
 * A data access object (DAO) providing persistence and search support for
 * ZbControl entities. Transaction control of the save(), update() and delete()
 * operations can directly support Spring container-managed transactions or they
 * can be augmented to handle user-managed Spring transactions. Each of these
 * methods provides additional information for how to configure it for the
 * desired type of transaction control.
 * 
 * @see com.woan.api.model.ZbControl
 * @author MyEclipse Persistence Tools
 */
public class ZbControDAO extends HibernateDaoSupport implements ZbControlIDAO{
	//根据视频id获取对讲信息的内容
	public List<ZbControl> FindVideoTalkMessageByVideoID(String videoid)
	{
		StringBuffer hql = new StringBuffer("from ZbControl");
		hql.append(" where videoId='"+videoid+"' order by createTime desc ");
		Session session = this.getSession();
		try
		{
			Query query = session.createQuery(hql.toString());
			List<ZbControl> list=query.list();
			
			return list;
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		return null;
	}
	public boolean SaveMessage(ZbControl zbcontrol)
	{
		try {
			getHibernateTemplate().save(zbcontrol);
			return true;
		} catch (RuntimeException re) {
			throw re;
		}
	}
}